package networkSimulation.simulation.virus

import networkSimulation.framework.{Edge, Graph}
import networkSimulation.monitor.Monitor

/**
 * Monitor when nodes die
 *
 * @author  Tim Caljé
 *          Jeroen De Raedt
 *          Jorick Van Aken
 */
class DeadMonitor[Method, Pub](name : String,graph : Graph[InfectablePerson, Edge[InfectablePerson]]) extends Monitor[Method, Pub, InfectablePerson, Edge[InfectablePerson]](name, graph) {

  /**
   * Custom implementation of the reaction to a notification of a publishing event of a Publisher.
   */
  @Override
  def notify(pub: Pub,  event: Method) {
    if (pub.isInstanceOf[InfectablePerson]) {
      if (event.toString() == classOf[InfectablePerson].getMethod("die").toString) {
        // log the death of a node
        log("Node " + pub.toString + " has died")
      }
    }
  }

}